<template>
  <div id="all">
    <h2>LogicFlow 是包装过一层的流程图工具,由国内滴滴团队提供开源技术</h2>
    <h3><a href="https://github.com/didi/LogicFlow">github地址：https://github.com/didi/LogicFlow</a></h3>
    <h3><a href="http://logic-flow.org/guide/start.html#%E5%AE%89%E8%A3%85">使用文档</a></h3>
    <h3><a href="https://gitee.com/free_pan/logicflow_vue_demo?_from=gitee_search">vue 案例</a></h3>
    <div>
      <h4>下面是示例</h4>
      <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
        <el-tab-pane label="基础引用" name="1">
          <div id="container"></div>;
        </el-tab-pane>
        <el-tab-pane label="自定义常用类型" name="2">
          <LogicFlow2></LogicFlow2>
        </el-tab-pane>
        <!-- <el-tab-pane label="角色管理" name="3">角色管理</el-tab-pane>
        <el-tab-pane label="定时任务补偿" name="4">定时任务补偿</el-tab-pane> -->
      </el-tabs>

    </div>
  </div>
</template>

<script>
import LogicFlow from "@logicflow/core";
import "@logicflow/core/dist/style/index.css";
import LogicFlow2 from "@/components/plugList/logicFlow2.vue";
export default {
  name: "",
  components: { LogicFlow2 },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  // 生命周期 - 载入后, Vue 实例挂载到实际的 DOM 操作完成，一般在该过程进行 Ajax 交互
  mounted() {
    this.init();
  },
  data() {
    return {
      activeName: "1",
    };
  },
  methods: {
    init() {
      const data = {
        // 节点
        nodes: [
          {
            id: 21,
            type: "rect",
            x: 100,
            y: 200,
            text: {
              value: "矩形节点",
              x: 100,
              y: 200,
            },
          },
          {
            id: 50,
            type: "circle",
            x: 300,
            y: 400,
            text: {
              value: "圆形节点",
              x: 300,
              y: 400,
            },
          },
        ],
        // 边
        edges: [
          {
            type: "polyline",
            sourceNodeId: 50,
            targetNodeId: 21,
          },
        ],
      };
      let width = document.body.clientWidth; //网页可见区域宽：
      let height = document.body.clientHeight; //网页可见区域高：
      // 渲染画布
      const lf = new LogicFlow({
        container: document.querySelector("#container"),
        // width: 700,
        // height: 600,
        width,
        height,
      });

      lf.render(data);
    },
    handleClick(tab, event) {
      // console.log(tab, event);
    },
  },
};
</script>

<style scoped="scoped">
.containers {
  position: absolute;
  background-color: #ffffff;
  width: 100%;
  height: 100%;
  border: 1px solid #e3e3e3;
}
.canvas {
  width: 100%;
  height: 100%;
}
.panel {
  position: absolute;
  right: 0;
  top: 0;
  width: 300px;
}
.lf-graph {
  border: 1px solid;
}
</style>
